# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#   
#   cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
#   Major.create(:name => 'Daley', :city => cities.first)
['ACOX', 'ACOT', 'ACOI', 'CSE'].each do |name|
  puts "creating organization: #{name}"
  Organization.find_or_create_by_name(name)
end

['Duty', 'Deployed', 'TDY', 'Leave'].each do |name|
  puts "creating status: #{name}"
  Status.find_or_create_by_name(name)
end

['Active Duty', 'Civilian', 'Contractor', 'Guard/Reserve'].each do |name|
  puts "creating employment: #{name}"
  Employment.find_or_create_by_name(name)
end

unless User.find_by_email('jacortinas@gmail.com')
  puts "creating an admin user"
  super_admin = User.new(:email => 'jacortinas@gmail.com', :first_name => 'Jose',
                         :last_name => 'Cortinas', :phone_number => '2109773713',
                         :organization_id => 1, :status_id => 1, :employment_id => 1,
                         :password => 'testpass', :password_confirmation => 'testpass')
  super_admin.save
  super_admin.has_role! :squadron_admin
  puts "admin user saved"
end

['Test Announcment 1', 'Test Announcement 2'].each do |msg|
  puts "creating announcement: #{msg}"
  announcement = Announcement.find_or_create_by_title(msg)
  announcement.body = "#{msg} Body #{'- test body' * 50}"
  announcement.user = User.first
  announcement.save
end